﻿using System;
using System.Collections.Generic;
using System.Linq;
using UniRx;
using UniRx.Triggers;
using UnityEngine;

namespace Studio
{
	// Token: 0x020005D9 RID: 1497
	public class DestinationPointer : MonoBehaviour
	{
		// Token: 0x06002647 RID: 9799 RVA: 0x000E07B4 File Offset: 0x000DE9B4
		private void ShowOrbit()
		{
			this.lineRenderer.enabled = true;
			float f = -0.017453292f * base.transform.eulerAngles.x;
			float y = base.transform.position.y;
			float num = this.initialVelocity;
			float num2 = Mathf.Sin(f);
			float num3 = Mathf.Cos(f);
			float num4 = DestinationPointer.gravity;
			float num5 = num * num2 / num4 + Mathf.Sqrt(this.Square(num) * this.Square(num2) / this.Square(num4) + 2f * y / num4);
			int num6 = 0;
			while ((float)num6 < this.vertexCount)
			{
				float num7 = (float)num6 * num5 / this.vertexCount;
				float d = num * num3 * num7;
				float d2 = num * num2 * num7 - 0.5f * num4 * this.Square(num7);
				Vector3 a = new Vector3(base.transform.forward.x, 0f, base.transform.forward.z);
				Vector3 item = base.transform.position + a * d + Vector3.up * d2;
				this.vertexes.Add(item);
				num6++;
			}
			this.objMarker.transform.position = this.vertexes.Last<Vector3>();
			this.lineRenderer.positionCount = this.vertexes.Count;
			this.lineRenderer.SetPositions(this.vertexes.ToArray());
			this.vertexes.Clear();
		}

		// Token: 0x06002648 RID: 9800 RVA: 0x000E0960 File Offset: 0x000DEB60
		private float Square(float num)
		{
			return Mathf.Pow(num, 2f);
		}

		// Token: 0x06002649 RID: 9801 RVA: 0x000E0970 File Offset: 0x000DEB70
		private void Start()
		{
			(from _ in this.LateUpdateAsObservable()
			where this.objMarker.activeSelf
			select _).Subscribe(delegate(Unit _)
			{
				this.ShowOrbit();
			});
			(from _ in this.LateUpdateAsObservable()
			where !this.objMarker.activeSelf
			select _).Subscribe(delegate(Unit _)
			{
				this.lineRenderer.enabled = false;
			});
		}

		// Token: 0x04002663 RID: 9827
		[SerializeField]
		private GameObject objMarker;

		// Token: 0x04002664 RID: 9828
		[SerializeField]
		private LineRenderer lineRenderer;

		// Token: 0x04002665 RID: 9829
		[SerializeField]
		private float vertexCount = 25f;

		// Token: 0x04002666 RID: 9830
		[SerializeField]
		private float initialVelocity = 1f;

		// Token: 0x04002667 RID: 9831
		private List<Vector3> vertexes = new List<Vector3>();

		// Token: 0x04002668 RID: 9832
		private static readonly float gravity = 9.81f;
	}
}
